using System;
using System.Collections.Generic;
using NHibernate.Validator.Engine;
using NUnit.Framework;
using RMH.Entities;

namespace RMH.UnitTests.Core
{
    [TestFixture]
    public class PatientSpecs_when_verifying_a_person_is_valid : base_test
    {
        Patient person = new Patient();
        ValidatorEngine engine = new ValidatorEngine();
        private InvalidValue[] validators;
        private List<InvalidValue> validatorList;

        public override void because()
        {
            this.validators = engine.Validate(person);
            validatorList = new List<InvalidValue>(validators);
        }

        [Test]
        public void ValidatesRequiredFields()
        {
            has_validator("FirstName");
            has_validator("LastName");
            has_validator("Address");
            has_validator("Diagnoses");
        }

       

        private void has_validator(string propertyName)
        {  
            validatorList.Find(x=>x.PropertyName.Equals(propertyName)).ShouldNotBeNull();
        }
    }
}